﻿/***************************************************************************
 * 文件名：DbUtil
 * 功能：假装有一个数据库
 * 说明：
 * -------------------------------------------------------------------------
 * 创建时间：2024/6/26 15:39:12
 * 创建人：金文旭
 * 邮箱： mohayashi@163.com
 * =========================================================================
 *
 * 修改人：   
 * 修改时间：   
 * 修改说明：   
 ***************************************************************************/
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ProjectDataChangeSync
{
    internal class DbUtil
    {
        private static List<DbUtil> instanceList=new List<DbUtil>();
        private static object _locker = new object();
        public static DbUtil GetInstance(string dbName)
        {
            if(!instanceList.Exists(value=>value.DatabaseName==dbName))
            {
                lock (_locker)
                {
                    if(!instanceList.Exists(value => value.DatabaseName == dbName))
                    {
                        instanceList.Add(new DbUtil(dbName));
                    }
                }
            }
            return instanceList.First(val=>val.DatabaseName == dbName);
        }
        internal string DatabaseName { get;}
        public DbUtil(string dbName)
        {
            DatabaseName = dbName;
        }

        public bool DoNonQuery(string Query)
        {
            if (Query == null || Query.Length == 0)
            {
                return false;
            }
            return true;
        }

        public ArrayList DoQuery(string Query)
        {
            if (Query == null || Query.Length == 0) { return null; }
            ArrayList result = new ArrayList();
            return result;
        }
    }
}
